package com.key.controller.admin.assetManagement;

import com.key.common.R;
import com.key.entity.AssetsAllocation;
import com.key.service.AssetsAllocationService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.spring.web.json.Json;

/**
 * @Author: li
 * @CreateTime: 2023-02-18  09:23
 */

@Controller
@RequestMapping("/assetsAllocation")
@Api(value = "资产调拨",tags = "资产调拨数据接口")
//资产调拨的相关功能
public class AssetsAllocationController {

    @Autowired
    private AssetsAllocationService allocationService;


    /**
     * 显示资产调拨单信息，包括高级搜索
     * @param assetsAllocation
     * @return
     */
    @RequestMapping(value = "/AllAssetsAllocationInfo",method = RequestMethod.POST)
    @ApiOperation(value = "资产调拨接口",notes = "查询所有资产调拨单信息",httpMethod = "post",response = Json.class)
    @ResponseBody
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R AllAssetsAllocationInfo(@RequestBody @ApiParam(name = "assetsAllocation",value = "资产调拨单信息 ",required = false) AssetsAllocation assetsAllocation){

        R r = allocationService.showAllAssetsAllocationInfo(assetsAllocation);

        return r;
    }


    /**
     * 确认调入选中的资产调拨单
     * @param allocationIds
     * @return
     */
    @RequestMapping(value = "/allocationConfirm",method = RequestMethod.POST)
    @ApiOperation(value = "资产调拨接口",notes = "修改资产调拨单状态信息以及相应资产状态",httpMethod = "post",response = Json.class)
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "allocationIds", value = "选中的资产调拨单id", paramType = "query", dataType = "int[]", required = true,allowMultiple = true),
            @ApiImplicitParam(name = "inDate", value = "调入日期", paramType = "query", dataType = "String", required = true)
    })
            @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R allocationConfirm(@RequestParam(name = "allocationIds") Integer[] allocationIds,
                               @RequestParam(name = "inDate") String inDate){

        R r = allocationService.allocationConfirm(allocationIds, inDate);

        return r;
    }


    /**
     * 取消调入
     * @param allocationIds
     * @return
     */
    @RequestMapping(value = "/allocationCancel",method = RequestMethod.POST)
    @ApiOperation(value = "资产调拨接口",notes = "取消调入即删除调拨单",httpMethod = "post",response = Json.class)
    @ResponseBody
    @ApiImplicitParam(name = "allocationIds",value = "选中的资产调拨单id，可多个",paramType = "query",dataType = "int[]",required = true,allowMultiple = true)
    @ApiResponses({
            @ApiResponse(code=200,message="取消成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R allocationCancel(@RequestParam(name = "allocationIds") Integer[] allocationIds){

        R r = allocationService.allocationCancel(allocationIds);

        return r;
    }


    /**
     * 查询单个调拨单信息
     * @param allocationId
     * @return
     */
    @RequestMapping(value = "/showAssetsAllocationInfo",method = RequestMethod.GET)
    @ApiOperation(value = "资产调拨接口",notes = "查询单个调拨单信息",httpMethod = "get",response = Json.class)
    @ResponseBody
    @ApiImplicitParam(name = "allocationId",value = "选中的资产调拨单号",paramType = "query",dataType = "int",required = true)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R showAssetsAllocationInfo(@RequestParam(name = "allocationId") Integer allocationId){

        R r = allocationService.showAssetsAllocationInfo(allocationId);

        return r;
    }

    /**
     * 根据调拨单号查询资产信息
     * @param allocationNum
     * @return
     */
    @RequestMapping(value = "/showAssetsByAllocationId",method = RequestMethod.GET)
    @ApiOperation(value = "资产调拨接口",notes = "根据调拨单号查询资产信息",httpMethod = "get",response = Json.class)
    @ResponseBody
    @ApiImplicitParam(name = "allocationNum",value = "选中的资产调拨单号",paramType = "query",dataType = "String",required = true)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R showAssetsByAllocationId(@RequestParam(name = "allocationNum") String allocationNum){

        R r = allocationService.showAssetsByAllocationNum(allocationNum);

        return r;
    }


    /**
     * 修改单个资产调拨单
     * @param inPerson
     * @param description
     * @return
     */
    @RequestMapping(value = "/updateAllocationInfo",method = RequestMethod.POST)
    @ApiOperation(value = "资产调拨接口",notes = "修改单个资产调拨单",httpMethod = "post",response = Json.class)
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "allocationId", value = "调拨单id", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "inPerson", value = "转移后使用员工", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "inCompany", value = "调入公司", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "description", value = "调拨说明", paramType = "query", dataType = "String", required = true)
    })

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateAllocationInfo(@RequestParam(name = "inPerson") String inPerson,
                                  @RequestParam(name = "allocationId") Integer allocationId,
                                  @RequestParam(name = "inCompany") String inCompany,
                                  @RequestParam(name = "description") String description){

        R r = allocationService.updateAllocationInfo(allocationId, inPerson, inCompany, description);

        return r;
    }

    /**
     * 根据调拨id删除调拨单
     * @param allocationIds
     * @return
     */
    @RequestMapping(value = "/deleteAllocationInfoById",method = RequestMethod.POST)
    @ApiOperation(value = "资产调拨接口",notes = "根据调拨id删除调拨单",httpMethod = "post",response = Json.class)
    @ResponseBody
    @ApiImplicitParam(name = "allocationIds",value = "选中的资产调拨单id,可多个",paramType = "query",dataType = "int[]",required = true,allowMultiple = true)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteAllocationInfoById(@RequestParam(name = "allocationIds") Integer[] allocationIds){

        R r = allocationService.deleteAllocationInfoById(allocationIds);

        return r;
    }











}
